<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<title></title>
		<script src="../lib/vue.js" type="text/javascript" charset="utf-8"></script>
		
	</head>
	<body>
		<div id="app">
			<input type="text"  v-model="firstname"/>+
			<input type="text"  v-model="lastname"/>=
			<input type="text"  v-model="fullname"/>
		</div>
		<script type="text/javascript">
			var vm =new Vue({
				el:'#app',
				data:{
					firstname:'',
					lastname:'',
					fullname:''
				},
				methods:{
					getFullname(){
						this.fullname = this.firstname + this.lastname
					}
				},
				watch:{//使用这个属性可以监视指定数据的变化，然后触发watch中指定的function
					'firstname':function(newVal,oldVal){
						//this.getFullname();
						this.fullname = newVal + this.lastname; 
					},
					'lastname':function(){
						//this.getFullname();
					}
				}
			})
		</script>
	</body>
</html>
